import os
import unittest
from cases.Base_Case import BASECASE
from config.config import DATA_PATH
from page.index import IndexPage
from page.住院公用页面.dianzhibingli__page import Binlibianjiqi
from page.住院医生站.住院医生站.shenqingdan__page import Shenqingdan
from page.住院公用页面.zhenduan__page import Zhenduanguanli
from page.住院医生站.住院医生站.zhuyuanyishengzhan__page import zhuyuanyishengzhan
from tools.sjqd_way import read_data_from_excel
class TestZhuyuanyishengzhan_kaijuchufangyiji(BASECASE):
    @classmethod
    def setUpClass(cls):
        ap = IndexPage()
        ap.jrym_no1('住院医生站')
    @classmethod
    def tearDownClass(cls):
        ap = IndexPage()
        ap.close_all_xxk()
        print("{}执行完毕-------------------------------------------------".format(cls))
    #添加长期医嘱
    # @unittest.skip
    def test_1_add_changqiyizhu(self):
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "测试患者")
        name = self.data[0][0]
        bp = zhuyuanyishengzhan()
        bp.input_hzxm(name)  # 输入患者姓名
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "住院医生站")
        ssbr,zyzt = self.data[0][0]
        bp.click_ssbr(ssbr)#选择所属患者
        bp.click_zyzt(zyzt)#选择在院状态
        bp.click_cx_btn()#点击查询按钮
        bp.click_hz1()#点击患者1
        bp.click_cqyz()#点击长期医嘱
        bp.add_cqyz(3)#添加新数据组
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "长期医嘱")
        yznr1, yf1, pc1 = self.data[0]
        yznr2, yf2, pc2 = self.data[1]
        yznr3, yf3, pc3 = self.data[2]
        bp.add_cqxm1(yznr1,yf1,pc1)
        bp.add_cqxm2(yznr2, yf2, pc2)
        bp.add_cqxm3(yznr3, yf3, pc3)
        bp.click_zc_btn()#点击暂存
        bp.click_tj_btn()#点击提交按钮
        bp.clicl_wxtsqd_btn()#点击确定按钮
    #添加临时医嘱
    # @unittest.skip
    def test_2_add_lingshiyizhu(self):
        bp = zhuyuanyishengzhan()
        bp.click_lsyz()#点击零时医嘱
        bp.add_lsyz(1)  # 添加新数据组
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "临时医嘱")
        yznr1, yf1, pc1 = self.data[0]
        yznr2, yf2, pc2 = self.data[1]
        bp.add_lsxm1(yznr1, yf1, pc1)
        bp.add_lsxm2(yznr2, yf2, pc2)
        bp.click_zc_btn()  # 点击暂存
        bp.click_tj_btn()  # 点击提交按钮
        bp.Rfind_tsqd()  # 重找提示
        bp.clicl_wxtsqd_btn()  # 点击确定按钮
    #添加申请单
    # @unittest.skip
    def test_3_add_shenqingdan(self):
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "申请单")
        sqzxks,sssqmc,sqzdys = self.data[0]
        bp = zhuyuanyishengzhan()
        cp = Shenqingdan()
        bp.click_lsyz()#点击临时医嘱
        bp.click_sqd_btn()#点击申请单
        cp.click_sssqd()#点击手术申请单
        cp.choose_sqzxks(sqzxks)#选择申请执行科室
        cp.choose_sssqmc(sssqmc)#选择手术申请名称
        cp.choose_sqzdys(sqzdys)#选择主刀医生
        cp.choose_sqmzfs()#选择麻醉方式
        cp.save_close()#点击保存并关闭
        bp.click_zc_btn() #点击暂存
        bp.click_tj_btn()#点击提交按钮
        bp.Rfind_tsqd() #重找提示
        bp.clicl_wxtsqd_btn()#点击提示保存

    #添加诊断
    # @unittest.skip
    def test_4_add_zhenduan(self):
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "诊断")
        zd = self.data[0][0]
        bp = zhuyuanyishengzhan()
        cp = Zhenduanguanli()
        bp.click_zd_btn()#点击诊断
        cp.click_xyzd()#点击西医诊断
        cp.input_zyzd(zd)#输入主要诊断
        cp.choose_rybq()#选择入院病情
        cp.choose_cybq()#选择出院情况
        cp.click_bc_btn()#点击保存
        cp.close_window()#关闭页面

    # 医生添加电子病历并签名
    # @unittest.skip
    def test_5_add_dianzibingli(self):
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "电子病历")
        mbmc,pwd = self.data[0]
        bp = zhuyuanyishengzhan()
        bp.click_dzbl_btn()#点击电子病历
        cp = Binlibianjiqi()
        cp.click_xz_btn()#点击新增按钮
        cp.click_yymb()#点击医院模板
        cp.input_mbmc(mbmc)
        cp.click_cz_btn()#点击查询
        cp.click_shuju1()#点击第一条模板
        cp.click_qd_btn()#点击确定按钮
        cp.qianming_(pwd)#签名
        # cp.quxiaoqianming_(pwd)#取消签名
if __name__ == '__main__':
    unittest.main()